#ifndef pktoon_TimeVal_h
#define pktoon_TimeVal_h

#ifdef WIN32
#include <WinSock2.h>
#else
#include <sys/time.h>
#endif

namespace catan
{
	struct TimeVal : public timeval
	{
	public:
		TimeVal();
		TimeVal(const TimeVal& other);
		bool operator < (const TimeVal& other) const;
		bool operator == (const TimeVal& other) const;
		bool operator != (const TimeVal& other) const;
		bool operator > (const TimeVal& other) const;
		bool operator <= (const TimeVal& other) const;
		bool operator >= (const TimeVal& other) const;
		TimeVal& operator = (const TimeVal& other);
		TimeVal operator - (const TimeVal& other) const;
		TimeVal operator + (const TimeVal& other) const;
		TimeVal& operator -= (const TimeVal& other);
		TimeVal& operator += (const TimeVal& other);

		double ToSeconds() const;
		long long ToMilliseconds() const;
		void Reload();

		static const TimeVal& Now();

	private:
		inline void Normalize();
	};
}

#endif
